// $getpost_array = array('1_pic', '2_pic', '3_pic', '4_pic', '5_pic');
// $requred_array = array();
// $data1 = $this->getpost->getpost_array($getpost_array, $requred_array);
$file_array = array('1_pic', '2_pic', '3_pic', '4_pic', '5_pic');
// foreach ($file_array as $key => $value) {
// $json_arr[] = $_FILES[$value];
// }
// echo json_encode($json_arr);
$i = 1;
foreach ($file_array as $key => $value) {
if (isset($_FILES[$value]) && $_FILES[$value]['size'] != 0) {
$name = $data['sn'] . '_' . $i . '.png';
$config['upload_path'] = './upload/'; // 存放路徑
$config['allowed_types'] = 'gif|jpg|png'; //
$config['overwrite'] = true;
$config['file_name'] = $name; // 文件名不使用原始名 (避免中文檔名錯誤)
$this->load->library('upload', $config);
$field_name = $value;
// print_r($name);
// echo json_encode($_FILES[$value]);
if (!$this->upload->do_upload($value)) {
// 失敗
echo $this->upload->display_errors();
} else {
// 成功
$file_data = $this->upload->data();
// echo json_encode($file_data);
}
}
$i = $i + 1;
}